﻿/*
--------------------------------------
File: AdjustRGB.cs
Project: Themaopdracht 7
Author: Roel Blaauwgeers
Description:
Higher rgb values etc.
--------------------------------------
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace THO7_Team8
{
    class AdjustRGB
    {

        /// <summary>
        /// Higher all the RGB values of an image array
        /// </summary>
        /// <param name="imageArray"></param>
        /// <param name="factor"></param>
        /// <returns>image array (int[])</returns>
        public void multiplyRGBValues(ref int[] imageArray, int factor)
        {

            int red, green, blue, alpha;

            for (int i = 0; i < imageArray.Length; i++)
            {
                blue = imageArray[i] & 255; //b
                green = (imageArray[i] >> 8) & 255; //g
                red = (imageArray[i] >> 16) & 255; //r
                alpha = (imageArray[i] >> 24) & 255;

                blue *= factor;
                green *= factor;
                red *= factor;

                if (red > 255)
                    red = 255;
                if (green > 255)
                    green = 255;
                if (blue > 255)
                    blue = 255;

                imageArray[i] = imageArray[i] & (int)0x000000;

                imageArray[i] |= (blue);
                imageArray[i] |= (green << 8);
                imageArray[i] |= (red << 16);
                imageArray[i] |= (alpha << 24);
            }
        }
    }
}
